package com.example.yibaodianzipinzheng.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.lang.NonNull;

@Slf4j
public class InitializeListener implements ApplicationListener<ApplicationEvent> {

    @Override
    public void onApplicationEvent(@NonNull ApplicationEvent applicationEvent) {
        if (applicationEvent instanceof ApplicationReadyEvent) {
            ApplicationReadyEvent applicationReadyEvent=(ApplicationReadyEvent)applicationEvent;
            ConfigurableApplicationContext applicationContext = applicationReadyEvent.getApplicationContext();
            String[] activeProfiles = applicationContext.getEnvironment().getActiveProfiles();
            // 窗口初始化
            WindowFocus windowFocus = applicationContext.getBean(WindowFocus.class);
            windowFocus.mouseMoveAndClick();
        }
    }

}
